package iscript.gameFramework.GameLite.content
{
	import flash.utils.Dictionary;
	import iscript.gameFramework.GameLite.events.GameContentEvent;
	
	internal class XMLDataContent implements IGameContent
	{
		
		private var _data:Dictionary = new Dictionary();
		private var _gameContent:GameContent
		
		public function XMLDataContent(gameContent:GameContent)
		{
			_gameContent = gameContent;
		}
		
		//public function get KEY():Array { return _data.getAllKeys() }	
		
		public function add(key:*, value:XML):void
		{
			if (_data[key] == null)
			{
				_data[key] = value;
				var event:GameContentEvent = new GameContentEvent(GameContentEvent.ADDXMLDATA);
				event.key = key;
				event.content = value;
				_gameContent.dispatchEvent(event);
				
				var e:GameContentEvent = new GameContentEvent(GameContentEvent.EVERYTHING)
				e.key = key;
				e.content = value;
				_gameContent.dispatchEvent(e);
			}
		}
		
		public function get(key:*):XML
		{
			return _data[key]
		}
		
		public function contain(key:*):Boolean
		{
			return _data[key] != null;
		}
		
		public function remove(key:*):void
		{
			delete _data[key];
		}
	
	}

}